import Vue from 'vue'
import VueRouter from 'vue-router'

// 1. 定义路由组件
import Home from '@/views/Home.vue'

// 0. 模块化
Vue.use(VueRouter)

// 2. 定义路由routes 信息
const routes = [
  {
    path:'/',
    redirect:'/home'
  },
  {
    path: '/home',
    name: 'home',
    component: Home
  },
  {
    path:'/find',
    name:'find',
    component:()=>import('@/views/Find.vue') // 路由懒加载
  },
  {
    path:'/mine',
    name:'mine',
    component:()=>import('@/views/Mine.vue')
  },
  {
    path:'/demo',
    name:'demo',
    component:()=>import('@/views/Demo.vue')
  },
  {
    path:"/404",
    component:()=>import('@/views/NotFound.vue')
  },
  {
    path:"*",
    redirect:'/404'
  }
]

// 3. 创建路由对象
const router = new VueRouter({
  routes,
  mode:"hash",
  base:""
})

// 4. 挂载到根实例 (导出暴露)
export default router
